#pragma once
#include "../Util/singleton.h"
#include <assert.h>

#ifdef _WIN32
  #include <Windows.h>
#endif

static const unsigned kuiConsoleDimX = 80; //X size of the console
static const unsigned kuiConsoleDimY = 25; //Y size of the console
static const unsigned kuiConsoleArea = kuiConsoleDimX * kuiConsoleDimY; //Area of the console

//Enumerator for the colors
enum eColor 
{
  eBlack = 0,
  eBlue,
  eGreen,
  eAqua,
  eRed,
  ePurple,
  eYellow,
  eWhite,
  eGray,
  eLightBlue,
  eLightGreen,
  eLightAqua,
  eLightRed,
  eLightPurple,
  eLightYellow,
  eLightWhite
};

//Graphic Manager class
class cGraphicManager : public cSingleton<cGraphicManager>
{
  private:
    char macBackBuffer[kuiConsoleArea]; //Backbuffer screen
    unsigned char macColorBuffer[kuiConsoleArea]; //Backbuffer color information
    unsigned char mcCurrentColour;  //Color to use to paint characters
    HANDLE  mHandle;
  protected:
    cGraphicManager(){;}
  public:
    friend class cSingleton<cGraphicManager>;
    void Init();
    void WriteChar(unsigned luiX, unsigned luiY, char lChar);
    void WriteChars(unsigned luiX, unsigned luiY, char *lacStr, unsigned luiLen);
    void WriteChars(unsigned luiX, unsigned luiY, char *lacStr);
    void SetColor(eColor leFore, eColor leBack);
    void SetForegroundColor(eColor leFore);
    void SetBackgroundColor(eColor leBack);
    void SwapBuffers();
    void ClearBuffer();
    void ShowCursor(bool lbShow);
    void Deinit();
};
